package com.eorchis.module.trainingclass.domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.hibernate.annotations.GenericGenerator;

import com.eorchis.core.basedao.entity.IBaseEntity;
import com.eorchis.core.basedao.entity.impl.AbstractBaseEntity;
import com.eorchis.module.department.domain.Department;

/**
 * Title: TrainingClass<br>
 * Description: 承办单位实体对象<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * @author RongSL
 * @createDate 2016-01-07
 * @version $Revision$
 */
@Entity
@Table(name = "CLASS_SCOPE_DEPARTMENT")
@JsonIgnoreProperties(value={"trainingClass","dept"})
public class ClassScopeDepartment extends AbstractBaseEntity implements IBaseEntity,Comparable {


	/**
	 * 活动状态：活动
	 */
	public final static Integer IS_ACTIVE_Y = new Integer(1);
	/**
	 * 活动状态：作废
	 */
	public final static Integer IS_ACTIVE_N = new Integer(2);
	
	private static final long serialVersionUID = 1L;
	private String scopeDeptId;//id
	private TrainingClass trainingClass;//班级ID
	private Department dept;//部门ID
	
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name = "SCOPE_DEPT_ID")
	public String getScopeDeptId() {
		return scopeDeptId;
	}
	public void setScopeDeptId(String scopeDeptId) {
		this.scopeDeptId = scopeDeptId;
	}

	@ManyToOne(cascade = CascadeType.ALL, optional = true)
	@JoinColumn(name="class_id", referencedColumnName="class_id")
	public TrainingClass getTrainingClass() {
		return trainingClass;
	}
	public void setTrainingClass(TrainingClass trainingClass) {
		this.trainingClass = trainingClass;
	}
	

	/**
	 * 获取部门
	 */
	@ManyToOne(fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name="DEPT_ID")
	public Department getDept() {
		return dept;
	}
	public void setDept(Department dept) {
		this.dept = dept;
	}
	@Override
    public int compareTo(Object o){      // 实现 Comparable 接口的抽象方法，定义排序规则
		ClassScopeDepartment p = (ClassScopeDepartment)o;
		return this.scopeDeptId.compareTo(p.scopeDeptId); // 升序排列，反之降序
    }
    @Override
    public boolean equals(Object o){     //equals
           boolean flag = false;
           if(o instanceof ClassScopeDepartment){
                  if(this.scopeDeptId == ((ClassScopeDepartment)o).scopeDeptId)
                         flag = true;
           }
           return false;          
    }    
}
